Skip to content

Mount binfmt_misc when sysinit starts - #14485

Closed
joshuaswarren wants to merge 1 commit into
omacom:quattrofrom
joshuaswarren:fix/binfmt-early-mount
Closed

joshuaswarren wants to merge 1 commit into
omacom:quattrofrom
joshuaswarren:fix/binfmt-early-mount

Conversation

@joshuaswarren

Copy link
Copy Markdown

Left to its automount, the binfmt_misc mount comes up about a second late, and sysinit.target waits with it.

systemd-binfmt registers the binfmt formats (33 with qemu-user-static-binfmt) right after the local file systems mount. Its first access triggers the binfmt_misc automount. The opening mount burst on an Omarchy machine (/home, /var/log, /var/cache/pacman/pkg, /boot, /boot/efi, fuse) trips systemd's mount rate limit of 5 events in 1 s (src/core/mount.c). While the limit holds, unit_start() returns -EAGAIN for every mount unit (src/core/unit.c). The binfmt_misc mount then waits about 1 s past the burst, and the network and sshd wait with it.

Measured numbers, recorded in omacom/omarchy-mac-pkgs#16, which this change replaces:

  • 14-inch M2 Max, systemd 262, 5 of 6 boots: Got automount request for /proc/sys/fs/binfmt_misc at 4.129 s, Mounting Arbitrary Executable File Formats at 5.094 s. Gap 0.962 to 0.966 s, and no unit started or finished inside it. The one boot whose request came after the window mounted at once.
  • 16-inch M1 Max: the same 0.965 s gap.
  • Lab boot on the 16-inch M1 Max (2026-10-07) with the mount enabled at boot start: no automount request in two boots. The baseline had one at 3.621 s, and userspace went from 4.70 s to 3.68 s and 3.75 s. That boot also raised the mount rate-limit burst (SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST=64) and shortened the Limine timeout, so part of that userspace gain does not come from this change alone.

systemd's own proc-sys-fs-binfmt_misc.mount ships [Install] WantedBy=sysinit.target, so enabling it mounts it as sysinit starts, before the burst. Nothing here is Mac-specific: any Omarchy machine with those binfmt formats sees the same stall.

Change

  • install/config/enable-services.sh: systemctl enable proc-sys-fs-binfmt_misc.mount, for new installs.
  • migrations/1791412720.sh: the same enable for existing installs. Idempotent, machine-wide, reports without failing if the enable fails.
  • test/shell.d/systemd-test.sh: new installs enable it, a migration enables it, and systemd's unit keeps WantedBy=sysinit.target. That proves the link resolves, not the ordering or the timing of a live boot.

Tests

test/all on this branch: 4122 checks pass, 33 skip, 41 fail. All 41 fail the same way on a clean quattro checkout on this host (23 test/shell.d files and 1 test/cli check), so they are host-environment failures, not from this change. test/shell.d/systemd-test.sh: 16 pass, 0 fail. The migration ran against a stubbed systemctl: it enables once, stays silent on a rerun, and reports without failing when the enable fails.

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High impact] Changes system initialization and boot ordering via systemd.

The host-dependent test failure should be fixed before merging.

Findings

  1. P1 Tests require host systemd files ▶
  2. P2 Migration behavior goes untested ▶

Summary

Enables proc-sys-fs-binfmt_misc.mount during startup instead of waiting for its first use.

  • New installs enable the unit through install/config/enable-services.sh.
  • Existing installs receive a machine-wide, repeat-safe migration.
  • Tests check the install command, a matching migration command, and the host unit’s WantedBy=sysinit.target.
  • joshuaswarren explicitly chose to report migration enable failures without stopping migrations.

Reviews (2) · Last reviewed commit: "Mount binfmt_misc when sysinit starts" · Reviewed by Greptile

Comment on lines +122 to +125
[[ -f /usr/lib/systemd/system/proc-sys-fs-binfmt_misc.mount ]] ||
fail "systemd ships proc-sys-fs-binfmt_misc.mount, the unit both enables name"
grep -qx 'WantedBy=sysinit.target' /usr/lib/systemd/system/proc-sys-fs-binfmt_misc.mount ||
fail "proc-sys-fs-binfmt_misc.mount must keep WantedBy=sysinit.target, or the enable creates no sysinit link"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Tests require host systemd files

If the test host lacks /usr/lib/systemd/system/proc-sys-fs-binfmt_misc.mount, these assertions make test/shell fail even when the checkout is correct. The suite is documented to run on any machine, including headless sandboxes. Move this check to the VM acceptance suite, or skip it when the required host files are unavailable.

Comment on lines +118 to +120
grep -rq 'systemctl enable proc-sys-fs-binfmt_misc.mount' "$ROOT/migrations" ||
fail "existing installs have no migration enabling the binfmt_misc mount"
pass "a migration enables the binfmt_misc mount on existing installs"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Migration behavior goes untested

This check only searches for an enable command anywhere under migrations. It never runs 1791412720.sh, so a broken enabled-state check or an enable failure that unexpectedly stops migrations can still pass. Add a test with stubbed systemctl and sudo that checks the enable call, reruns with the unit enabled, and covers an enable failure.

@axelfontaine

Copy link
Copy Markdown
Contributor

Related binfmt_misch change:

@joshuaswarren
joshuaswarren force-pushed the fix/binfmt-early-mount branch from 4e21446 to 5600993 Compare October 8, 2026 23:38
@joshuaswarren

Copy link
Copy Markdown
Author

Independent layers of the same stack: #6736 rewrites the binfmt registrations themselves (adds the O and C flags through /etc/binfmt.d overrides); this PR only moves the binfmt_misc mount earlier so sysinit.target stops waiting on the mount's rate-limited automount. The file sets are disjoint (this changes install/config/enable-services.sh plus a migration; #6736 adds its own apply command, pacman hook and tests), so they merge in either order and both stay useful together.

@omarchybot omarchybot added the bug Something isn't working label Oct 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 5600993. The stall is real, but quattro already fixes it, so this change is no longer needed.

#15175 (d100314, merged 2026-10-13) adds etc/systemd/system/systemd-binfmt.service.d/10-eager-mount.conf, which gives systemd-binfmt.service a Wants=proc-sys-fs-binfmt_misc.mount. The service is in sysinit.target.wants, so the mount joins the boot's first transaction and never waits on the automount. It also adds proc-sys-fs-binfmt_misc.mount.d/10-omarchy-conditions.conf to keep the automount's path and read/write conditions. These files ship in the settings package's etc/ tree, so existing installs get them on their next update without a migration.

On a worker built from the current Omarchy ISO (systemd 262, x86_64, 31 binfmt formats, with #15175's drop-ins installed), boot mounted /proc/sys/fs/binfmt_misc at 2.510 s together with the other API file systems. There was no automount request in the journal, systemd-binfmt.service took 45 ms, and no units failed. test/shell.d/systemd-test.sh passes at this head on the same worker. I did not boot this branch, because quattro no longer shows the delay it removes.

The only extra case this branch covers is mounting binfmt_misc at sysinit when systemd-binfmt.service is not in the transaction at all. There, nothing registers formats, so the stall doesn't happen either. Two smaller points, for completeness: migrations/1791412720.sh exits 0 when the enable fails, so it is marked done and never retried, which agents/skills/migrations.md rules out. And the last test reads the host's /usr/lib/systemd/system instead of the repository.

The second opinion was Codex Medium. It reached the same conclusion: the mechanism is real and #15175 already covers it. It also raised the migration's exit status as its own finding. It may have read this review's notes, so its agreement is not guaranteed to be independent.

This now waits on the maintainer, and I recommend closing it as superseded by #15175. Thanks for the measurements, @joshuaswarren. Your numbers match what #15175 found on its own test image.

@joshuaswarren

Copy link
Copy Markdown
Author

Thanks for looking at this. I'm closing it. #15175 handles it now. That one mounts binfmt_misc before registration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants